<?php

/**
 * @copyright        2017 opencart.cn - All Rights Reserved
 * @author:          Sam Chen <sam.chen@opencart.cn>
 * @created:         2017-08-25 12:54:43
 * @modified by:     Sam Chen <sam.chen@opencart.cn>
 * @modified:        2017-10-26 09:33:47
 */

class ControllerExtensionModuleGdImageText extends Controller {
  public function index($setting) {
    if ($this->config->get('is_mobile')) return;

    $this->load->language('extension/module/gd_module');

    if ($this->request->server['HTTPS']) {
      $base = HTTPS_SERVER;
    } else {
      $base = HTTP_SERVER;
    }

    $data['title'] = $setting['title'];
    $data['button_more'] = $this->language->get('button_more');

    $data['items'] = array();
    foreach ($setting['items'] as $item) {
      if (!array_get($item, 'image')) continue;
      $data['items'][] = array(
        'image'     => $base . 'image/' . $item['image'],
        'href'      => $item['url'],
        'title'     => $item['title'],
        'text'     => $item['text'],
        'direction' => $item['direction']
      );
    }

    if ($data['items']) {
      return $this->load->view('extension/module/gd_image_text.tpl', $data);
    }
  }
}
